<!--
 * @Description: 
 * @Version: 2.0
 * @Autor: wsh
 * @Date: 2024-01-31 09:52:33
 * @LastEditors: wsh
 * @LastEditTime: 2024-06-03 15:19:54
-->
<template>
  <BaseContainer>
    <el-tabs v-model="activeName" class="demo-tabs">
      <el-tab-pane v-for="item in dictList['BUSINESSTYPE']" :key="item.value" :label="item.label"
        :name="item.value"></el-tab-pane>
    </el-tabs>

    <aplid-base-crud :key="activeName" :paramsObj="{
      businessType: activeName,
    }" ref="crud" v-bind="baseConfig" :operateFormate="operateFormate">
      <template #detailDialog>
        <div>
          <el-timeline>
            <el-timeline-item v-for="(activity, index) in activities" :key="index" :icon="activity.icon"
              :type="activity.type" color="#0bbd87" :size="activity.size" :hollow="activity.hollow"
              :timestamp="activity.createTime">
              {{ activity.processStatusLabel }}
              <div v-if="activity.processStatus == '-1'" style="margin-top: 5px;">驳回原因：{{ activity.processNote }}</div>
            </el-timeline-item>
          </el-timeline>
        </div>
      </template>
      <template #tableReportDialog="{ row }">
        <TableReport :nowRowData="row"></TableReport>
      </template>
      <template #examineDialog="{ row }">
        <examine :nowRowData="row" @refresh="handleRefresh"></examine>
      </template>
    </aplid-base-crud>
  </BaseContainer>
</template>

<script setup lang="ts">
import { baseConfig } from './config.js'
import api from '@/apiMod'
import TableReport from './detail/index.vue'
import examine from './examine/index.vue'
import { useCommonStore } from '@/stores/common'
const { dictList } = storeToRefs(useCommonStore())
const crud = ref(null)
const activities = ref([])

const activeName = ref('1')

const operateFormate = (row, type) => {
  return new Promise(async (resolve, reject) => {
    if (type == 'detail') {
      const params = {
        processCode: row.processCode,
      }
      const res = await api.view_bscBusinessProcessLog_list(params)
      activities.value = res.data
      resolve(row)
    } else {
      resolve(row)
    }
  })
}

const handleRefresh = () => {
  nextTick(() => {
    crud.value?.refreshChange()
  })
}
</script>

<style scoped lang="scss"></style>
